﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace VisaValeCheck
{
    /// <summary>
    /// Interaction logic for NumeroWindow.xaml
    /// </summary>
    public partial class NumeroWindow : Window
    {
        public NumeroCartao NumeroCartao 
        { 
            get { return new NumeroCartao(lstCartao.Text); }
            set { lstCartao.Text = value.NumeroFormatado; }
        }

        public NumeroWindow()
        {
            InitializeComponent();
        }

        private void btnCartao_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CartaoManipulation.ColocarCartaoAtivo(new NumeroCartao(lstCartao.Text));
                this.DialogResult = true;
                this.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Erro", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                lstCartao.Focus();
            }
        }

        private void btnDeletar_Click(object sender, RoutedEventArgs e)
        {
            if (CartaoManipulation.Deletar((NumeroCartao)lstCartao.SelectedValue))
            {
                System.Windows.Forms.MessageBox.Show("Cartão removido.", "Remoção", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);                
            }
        }
    }
}
